<link rel="stylesheet"  type="text/css" href="__STATIC__/wechat/css/swiper.min.css">
<script type="text/javascript" src="__STATIC__/wechat/js/swiper.min.js"></script>
<div class="sectionY">
	<!--<a href="javascript:void(0);">-->
	<!--<img src="__STATIC__/wechat/images/a1.png" class="a1" alt="">-->
	<!--</a>-->
	<div class="sli">
		<a href="javascript:void(0);" class="select">货品</a>
		<a href="javascript:void(0);">评价</a>
		<a href="javascript:void(0);">详情</a>
	</div>
	<!--<a href="javascript:void(0);">-->
	<!--<img src="__STATIC__/wechat/images/a3.png" class="a2" alt="">-->
	<!--</a>-->
</div>
<!--货品-->
<div id="good" class="kong1"></div>
<div class="section1">
	{if $goods['percentage_title']!=''}
	<span class="s1">{$goods['percentage_title']}</span>
	{/if}
	<div class="ppp">
		<div class="swiper-container" id="mm">
			<div class="swiper-wrapper">
				{if $goods['video']!=''}
				<div class="swiper-slide">
					<div class="video-bor">
						<video id="video" src="{$goods['video']}" controls="controls"></video>
						<img class="video-bk" src="{$goods['group_images'][0]}"/>
						<img id="video-point" class="video-point" src="__STATIC__/wechat/images/video-point.png"/>
					</div>
				</div>
				{/if}
				{volist name="$goods['group_images']" id="item"}
				<div class="swiper-slide"><img src="{$item}"/></div>
				{/volist}
			</div>
			<div class="swiper-pagination"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(function () {
        //轮播
        var swiper = new Swiper('#mm', {
            spaceBetween: 30,
            centeredSlides: true,
            pagination: {
                el: '.swiper-pagination',
                clickable: true
            },
			on:{
                slideChangeTransitionStart: function(){
                    if($("#video").length>0){
						if($("#video").get(0).play){
                            $("#video").trigger("pause");
                            $(".video-bk").show();
                            $("#video-point").show();
						}
					}
                }
			}
        });
		$("#video-point").click(function () {
			$(this).hide();
			$(".video-bk").hide();
			$("#video").trigger("play");
        });
    });
</script>

<script type="text/javascript">
    function countDown(obj,endTime){
        var time_start = new Date().getTime(); //设定当前时间
        var time_end =  parseInt(endTime); //设定目标时间
        // 计算时间差
        var time_distance = time_end - time_start;
        // 天
        var int_day = Math.floor(time_distance/86400000);
        time_distance -= int_day * 86400000;
        // 时
        var int_hour = Math.floor(time_distance/3600000);
        time_distance -= int_hour * 3600000;
        // 分
        var int_minute = Math.floor(time_distance/60000);
        time_distance -= int_minute * 60000;
        // 秒
        var int_second = Math.floor(time_distance/1000);
        // 时分秒为单数时、前面加零
        if(int_day < 10 && int_day > 0){
            int_day = "0" + int_day;
        }else if(int_day < 0){  // 日期已过
            if(obj=='#yushou-time'){
                $(obj).html("预售已结束");
                $(".twox").removeClass('c2').addClass("huise");
                $(".twox .p2").html("预售已结束");
			}else{
                if($(obj).hasClass('oneTime')){
                    $(obj).html("已");
                }else{
                    $(obj).html("已到时间");
                }

            }
            return false;
        }
        if(int_hour < 10){
            int_hour = "0" + int_hour;
        }
        if(int_minute < 10){
            int_minute = "0" + int_minute;
        }
        if(int_second < 10){
            int_second = "0" + int_second;
        }
        if(int_day<=0 && int_hour<=0 && int_minute <=0 && int_second<=0){
            if(obj=='#yushou-time'){
                $(obj).html("预售已结束");
                $(".twox").removeClass('c2').addClass("huise");
                $(".twox .p2").html("预售已结束");
            }else{
                if($(obj).hasClass('oneTime')){
                    $(obj).html("已");
				}else{
                    $(obj).html("已到时间");
				}

            }
            return false;
        }
        // 显示时间
        if(int_day>0){
            var result = parseInt(int_day)+"天"+int_hour+":"+int_minute+":"+int_second;
		}else{
            var result = int_hour+":"+int_minute+":"+int_second;
		}
        $(obj).text(result);
        // 设置定时器
        setTimeout("countDown("+"'"+obj+"'"+","+endTime+")",1000);
    }
</script>
<div class="section2">
	<div class="a1 clearfix">
		<div class="container clearfix">
			<div class="z1">
				<span class="s1">￥{$goods.price}</span>
				<span class="s2">￥{$goods.original_price}</span>
			</div>
			<div class="z2">
				{if $goods['is_presell']==0}
				<p class="p1">已售{$goods.sales_nums}件</p>
				{/if}
				{if $goods['is_presell']==1}
					{if $goods['presell_start_time'] > time()}
					<p class="p1">预售还未开始</p>
					{elseif $goods['presell_end_time']>0}
					<p id="yushou-time" class="p1" >预售进行中</p>
					<script>
                        countDown("#yushou-time",{php}echo $goods['presell_end_time']*1000;{/php});
					</script>
					{else/}
					<p class="p1">预售已结束</p>
					{/if}
				{/if}
				{if $goods['is_presell']==2}
				<p class="p1">已拼{$goods.sales_nums}件</p>
				{/if}
			</div>
		</div>
	</div>
	<div class="a2">
		<div class="container clearfix">
			<p class="p1">
				<span class="s1">/</span>
				<img src="{$global.coin.img_url}" alt="">
				<span class="s2">{$goods.coin}</span>
			</p>
		</div>
	</div>
	<div class="a3">
		<div class="container">
			<div style="width: 100%" class="w1">
				<p class="p1 chao2">{$goods.title}</p>
			</div>
		</div>
	</div>
	<div style="height: auto;padding: 6px 0;" class="ge1">
		{volist name="$goods['rebate']" id="item"}
		<span class="rebate-item">{$item}</span>
		{/volist}
	</div>
	<div id="onex" class="a4">
		<div class="container clearfix">
			<div class="r1">
				<span id="onex-se" class="s1">未选</span>
			</div>
			<div class="r2 chao">
				<p class="p1 chao">
					<span id="onex-tit" class="s1 chao">{$goods.choose_title}</span>
					<span id="onex-num" class="s2"></span>
				</p>
			</div>
			<div class="r3">
				<img src="__STATIC__/wechat/images/a6.png" alt="">
			</div>
		</div>
	</div>
</div>
{if $goods['is_presell']==2&&$group_num>0}
<div class="ge"></div>
<div class="section3">
	<div class="a1">
		<div class="container clearfix">
			<p class="p1">{$goods.group_history.title}</p>
			<p class="p2">
				<a id="more" href="javascript:void(0);">查看更多<img src="__STATIC__/wechat/images/a7.png" alt=""></a>
			</p>
		</div>
	</div>
	<div class="ge1"></div>
	<div class="a2">
		<div class="ko">
			<ul class="news_li">
				<li class="clearfix">
					{volist name="$goods['group_history']['list']" id="item"}
					<div class="k1 clearfix">
						<div class="b1">
							<img src="{$item.avatar}" alt="">
						</div>
						<div class="b2">
							<p class="p1 chao">{$item.name}</p>
						</div>
						<div class="b3">
							<a data-id="{$item._id}" class="qupin" href="javascript:void(0);">去拼单</a>
						</div>
						<div class="b4 ">
							<p class="p1 chao">还差<span class="s1">{$item.leave_num}人</span>拼成</p>
							<p class="p2 chao"><span class="s2 timer gp-{$item._id}"></span></p>
						</div>
						<script>
                            countDown('.gp-{$item._id}',{php}echo $item['end_time']*1000;{/php});
						</script>
					</div>
					{/volist}
				</li>
			</ul>
			<ul class="swap"></ul>
		</div>
	</div>
</div>
<script type="text/javascript">
    $("#more").click(function () {
        loadG();
        $(".pindan").show();
    });

    var page=1;

    $("body").on("click","#loadMoresss",function(){
        loadG();
    });

    function loadG() {
        var goods_id = "{$goods._id}";
        $.ajax({
            type:'post',
            url:"{:url('Goods/groupList')}",
            data:{id:goods_id,page:page},
            cache:false,
            dataType:'JSON',
            success:function(data){

                if(data.status==0){
                    var show = data.data.show;
                    if(show==1){
                        $("#loadMoresss").css('display','block');
					}else{
                        $("#loadMoresss").css('display','none');
					}
					var list = data.data.list;
                    if(list.length>0){

                        var html = '';
						for (i=0;i<list.length;i++){
							html += '<li class="clearfix">'
									+'<div class="a1"><img src="'+list[i]['avatar']+'" alt=""></div>'
									+'<div class="a2"><p class="p1 chao">'+list[i]['name']+'</p><p class="p2"><span class="s1"></span><span class="s2 gps-'+list[i]['_id']+'"></span></p></div>'
									+'<div class="a3"><p class="p1 chao">还差<span class="s1">'+list[i]['leave_num']+'人</span></p></div>'
									+ '<div class="a4"><a onclick="" data-id="'+list[i]['_id']+'" class="qupin" href="javascript:void(0);">去拼单</a></div>'
									+'</li>';
						}
						$("#gsbor").append(html);
                        for (i=0;i<list.length;i++){
                            var endtime = parseInt(list[i]['end_time'])*1000;
                            countDown('.gps-'+list[i]['_id'],endtime);
                        }
						page++;
					}
                }else{
                    $.Toast('提示',data.info,'error');
                }
            },
            error:function(e){

            },
            beforeSend:function(e){

            }
        });
    }

</script>
{/if}

<!-- 正在拼单 -->
<div class="pindan">
	<div class="center">
		<div class="title">
			<p class="p1">正在拼单</p>
			<img src="__STATIC__/wechat/images/a12.png" alt="" class="close_btn_pindan">
		</div>
		<div class="item">
			<ul id="gsbor">

			</ul>
			<a onclick="" id="loadMoresss" style="text-align:center;border-radius:3px;font-size:0.8rem;display: block;width: 37%;line-height: 25px;background:#ff4546;color: #fff;margin: 10px auto;" href="javascript:void(0);">加载更多</a>
		</div>
	</div>
</div>
<!-- 参与拼单 -->
{if $one}
<div class="join1" style="display: block">
	<div class="center">
		<div class="a1">
			<div class="container">
				<a href="javascript:void(0);">
					<img src="__STATIC__/wechat/images/a12.png" alt="" class="close_btn_join1">
				</a>
			</div>
		</div>
		<div class="a2">
			<p class="p1"><span class="s2">参与</span><span id="oneTit" class="s1 chao">{$one.name}</span><span class="s2">的拼单</span></p>
			<p class="p2">仅剩<span class="s1" id="oneLea">{$one.leave_num}</span>个名额，<span id="oneTime{$one._id}" class="s2 oneTime">10:10:10</span>结束</p>
			<script>
                countDown("#oneTime{$one._id}",{php}echo $one['end_time']*1000;{/php});
			</script>
		</div>
		<div id="oneBorb" class="a3 clearfix" style="overflow-x: scroll;width: auto;white-space:nowrap;">
			{volist name="$one['list']" id="item"}
			<div class="g1">
				<img style="border-radius: 100%" src="{$item.avatar}" alt="">
				{if $item['str']!=''}
				<span class="s1">{$item.str}</span>
				{/if}
			</div>
			{/volist}
		</div>
		<div class="a4">
			<a id="joinGroup" data-id="{$one._id}" href="javascript:void(0);">参与拼团</a>
		</div>
	</div>
</div>
{else/}
<div class="join1">
	<div class="center">
		<div class="a1">
			<div class="container">
				<a href="javascript:void(0);">
					<img src="__STATIC__/wechat/images/a12.png" alt="" class="close_btn_join1">
				</a>
			</div>
		</div>
		<div class="a2">
			<p class="p1"><span class="s2">参与</span><span id="oneTit" class="s1 chao">庄哥哥哥庄哥哥哥庄哥哥哥庄哥哥哥</span><span class="s2">的拼单</span></p>
			<p class="p2">仅剩<span class="s1" id="oneLea">1</span>个名额，<span id="" class="s2 oneTime">10:10:10</span>结束</p>
		</div>
		<div id="oneBorb" class="a3 clearfix" style="overflow-x: scroll;width: auto;white-space:nowrap;">
			
		</div>
		<div class="a4">
			<a id="joinGroup" data-id="" href="javascript:void(0);">参与拼团</a>
		</div>
	</div>
</div>
{/if}
<script type="text/javascript">
	$("#joinGroup").click(function () {
	    var gidid = $(this).attr('data-id');
        $("input[name=group_id]").val(gidid);
	    $(".pindan").hide();
	    $(".join1").hide();
        spec();
    });
    $("body").on("click",".qupin",function(){
        var group_id = $(this).attr('data-id');
        $.ajax({
            type:'post',
            url:"{:url('Goods/group')}",
            data:{group_id:group_id},
            cache:false,
            dataType:'JSON',
            success:function(data){

                if(data.status==0){
                    var da = data.data;
                    $("#oneTit").html(da.name);
                    $("#oneLea").html(da.leave_num);
                    var lish = '';
					var li = da.list;
					for (i=0;i<li.length;i++){
					    if(li[i]['str']!=''){
					        var strs = '<span class="s1">'+li[i]['str']+'</span>';
						}else{
					        var strs = '';
						}
						lish += '<div class="g1">'
                            +'<img style="border-radius: 100%;" src="'+li[i]['avatar']+'" alt="">'
							+strs
                            +'</div>';
					}
					$("#oneBorb").html(lish);
                    $("#joinGroup").attr('data-id',da['_id']);
                    $(".oneTime").attr('id','oneTime'+da['_id']);
                    countDown('#oneTime'+da['_id'],parseInt(da['end_time'])*1000);
                    $(".join1").show();

                }else{
                    $.Toast('提示',data.info,'error');
                }
            },
            error:function(e){

            },
            beforeSend:function(e){

            }
        });
    });
</script>
<div class="ge"></div>
<div class="section4">
	<div class="container clearfix">
		<div class="a1">
			<img src="{$goods.business_img_url}" alt="">
		</div>
		<div class="a2">
			<p class="p1 chao">{$goods.business_title}</p>
		</div>
		<div class="a3">
			<a href="{:url('Utils/down')}">进店逛逛</a>
		</div>
	</div>
</div>
<!--评价-->
<div id="comment" class="ge"></div>
<div class="ping_num">
	<span>评价({$goods.comment_num})</span>
	{if $goods['comment_num']>10}
	<a href="{:url('Utils/dowsn')}" style="float: right;color:#333;">查看全部</a>
	{/if}
</div>
<div class="ping_section1">
	{volist name="$goods['comment']" id="item"}
	<div class="a1">
		<div class="container">
			<div class="l1 clearfix">
				<div class="j1">
					<img src="{$item.avatar}" alt="">
				</div>
				<div class="j2">
					<p class="p1">{$item.nick_name}</p>
					<p class="p2">
						<?php
						for($ii=1;$ii<=$item['star'];$ii++){
						?>
						<img src="__STATIC__/wechat/images/star-r.png" />
						<?php
						}
						?>
						<?php
						for($ii=1;$ii<=(5-$item['star']);$ii++){
						?>
						<img src="__STATIC__/wechat/images/star-g.png" />
						<?php
						}
						?>

					</p>
				</div>
				<div class="j3">
					<p class="p1">{$item.comment_time}</p>
				</div>
			</div>
			<div class="l2">
				<div class="center">
					<p style="font-size: 0.8rem;color:#CBCBCB;">{$item.spec_title}</p>
					<p class="p1">{$item.content}</p>
				</div>
			</div>
		</div>
	</div>
	{/volist}
</div>
<!--详情-->
<div id="detail" class="xiang_bk">
	<div></div>
	<span>详情</span>
</div>
<div class="xiang_section1">{$goods.detail}</div>

<!--购买-->
<div class="ge"></div>
<div class="kong"></div>
<div class="foot_1" >
	<div class="a1">
		<p class="p1">
			{if $goods['is_collection']}
			<img src="__STATIC__/wechat/images/a11.png" alt="">
			{else/}
			<img src="__STATIC__/wechat/images/a10.png" alt="">
			{/if}
		</p>
		<p class="p2">收藏</p>
	</div>

	{if $goods['is_presell']==2}
	<div class="a2 c1 twox normal-btn">
		<a href="javascript:void(0);">
			<p class="p1">￥{$goods.price}</p>
			<p class="p2">单独购买</p>
		</a>
	</div>
	<div class="a2 c2 twox group-btn">
		<a href="javascript:void(0);">
			<p class="p1">￥{$goods.group_price}</p>
			<p class="p2">立即团购</p>
		</a>
	</div>
	{elseif $goods['is_presell']==1/}
		{if $goods['presell_start_time'] > time()}
		<div style="width: 80%" class="a2 twox normal-btn huise">
			<a href="javascript:void(0);">
				<p class="p1">￥{$goods.price}</p>
				<p class="p2">预售还未开始</p>
			</a>
		</div>
		{elseif $goods['presell_end_time']>time()}
		<div style="width: 80%" class="a2 c2 twox normal-btn">
			<a href="javascript:void(0);">
				<p class="p1">￥{$goods.price}</p>
				<p class="p2">立即购买</p>
			</a>
		</div>
		{else/}
		<div style="width: 80%" class="a2 twox normal-btn huise">
			<a href="javascript:void(0);">
				<p class="p1">￥{$goods.price}</p>
				<p class="p2">预售已结束</p>
			</a>
		</div>
		{/if}
	{else/}
	<div style="width: 80%" class="a2 c2 twox normal-btn">
		<a href="javascript:void(0);">
			<p class="p1">￥{$goods.price}</p>
			<p class="p2">立即购买</p>
		</a>
	</div>
	{/if}
</div>

<!-- 商品规格 -->
<div class="shop_set">
	<div class="shop_set1">
		<div class="a1 clearfix">
			<div class="r1">
				<img id="sp-sh-img" src="{$goods.spec.def.img_url}" alt="">
			</div>
			<div class="r2">
				<p id="sp-sh-tit" class="p1 chao2">{$goods.spec.def.title}</p>
			</div>
			<div class="r3">
				<img src="__STATIC__/wechat/images/a12.png" alt="" class="close_btn_set">
			</div>
		</div>
		<div class="a3 slide_qie">

			<ul>
				<li class="def" data-id="{$goods.spec.def._id}" data-img="{$goods.spec.def.img_url}" data-title="{$goods.spec.def.title}" data-price="{$goods.spec.def.price}" data-group-price="{$goods.spec.def.group_price}" style="display: none"></li>
				{volist name="$goods['spec']['list']" id="item"}
				<li data-id="{$item._id}" data-img="{$item.img_url}" data-title="{$item.title}" data-price="{$item.price}" data-group-price="{$item.group_price}">{$item.title}</li>
				{/volist}
			</ul>
		</div>
		<div class="a2 clearfix">
			<div class="t1">
				<span class="s1">数量</span>
			</div>
			<div class="t2">
				<img id="num-del" src="__STATIC__/wechat/images/icon_subtraction.png" alt="">
				<span id="num-bor" class="s1">1</span>
				<img id="num-add" src="__STATIC__/wechat/images/icon_add.png" alt="">
			</div>
		</div>
		<div style="position: normal;" class="foot_1">
			{if $goods['is_presell']==2}
			<div style="padding: 0;width: 50%;" class="a2 c1 normal-btn subbtn">
				<a href="javascript:void(0);">
					<p class="p1">￥{$goods.spec.def.price}</p>
					<p class="p2">单独购买</p>
				</a>
			</div>
			<div style="padding: 0;width: 50%;" class="a2 c2 group-btn subbtn2">
				<a href="javascript:void(0);">
					<p class="p1">￥{$goods.spec.def.group_price}</p>
					<p class="p2">立即团购</p>
				</a>
			</div>
			{else/}
			<div style="padding: 0; width: 100%" class="a2 c2 normal-btn subbtn">
				<a href="javascript:void(0);">
					<p class="p1">￥{$goods.spec.def.price}</p>
					<p class="p2">立即购买</p>
				</a>
			</div>
			{/if}
		</div>
	</div>
</div>
<input type="hidden" name="goods_type" value="{$goods.is_presell}" />
<input type="hidden" name="spec_id" value="" />
<input type="hidden" name="num" value="1" />
<input type="hidden" name="price" value="{$goods.price}" />
<input type="hidden" name="group_price" value="{$goods.group_price}" />
<input type="hidden" name="group_id" value="0" />

<script type="text/javascript">

	//唤起规格
    $("#onex").click(function () {
        spec();
    });

    $(".twox").click(function () {
        if($(this).hasClass('huise')){
			return false;
		}else{
            spec();
		}

    });
	//加数量
    $("#num-add").click(function () {
        var nownum = parseInt($("#num-bor").html());
        nownum++;
        $("#num-bor").html(nownum);
        var nprice = parseFloat($("input[name=price]").val());
        var ngroup_price = parseFloat($("input[name=group_price]").val());
        $(".normal-btn .p1").html('￥'+(nprice*nownum));
        $(".group-btn .p1").html('￥'+(ngroup_price*nownum));
        $("input[name=num]").val(nownum);
        $("#onex-num").html('x'+nownum);
    });
	//减数量
    $("#num-del").click(function () {
        var nownum = parseInt($("#num-bor").html());
        nownum--;
        if(nownum<=1){
            nownum=1;
		}
        $("#num-bor").html(nownum);
        var nprice = parseFloat($("input[name=price]").val());
        var ngroup_price = parseFloat($("input[name=group_price]").val());
        $(".normal-btn .p1").html('￥'+(nprice*nownum));
        $(".group-btn .p1").html('￥'+(ngroup_price*nownum));
        $("input[name=num]").val(nownum);
        $("#onex-num").html('x'+nownum);
    });
	//初始化规格
	function spec() {
	    if($(".slide_qie .select").length>0){
            var def = $(".slide_qie .select");
		}else{
            var def = $(".slide_qie .def");
		}

        $("#sp-sh-img").attr('src',def.attr('data-img'));
        $("#sp-sh-tit").html(def.attr('data-tit'));
		$("input[name=spec_id]").val(def.attr('data-id'));
        $("#onex-tit").html(def.attr('data-title'));
        var price = parseFloat(def.attr('data-price'));
        var group_price = parseFloat(def.attr('data-group-price'));
        $("input[name=price]").val(price);
        $("input[name=group_price]").val(group_price);
        var num = parseInt($("input[name=num]").val());

        $(".normal-btn .p1").html('￥'+(price*num));
        $(".group-btn .p1").html('￥'+(group_price*num));
        $("#onex-se").html('已选');
        $("#onex-num").html('x'+num);
        $(".shop_set").show();
    }
	
    $(function(){
        $(".close_btn_pindan").click(function(){
            $(".pindan").hide();
        });
        $(".close_btn_set").click(function(){
            $(".shop_set").hide();
        });
        $(".close_btn_join1").click(function(){
            $(".join1").hide();
        });
        //选择规格
        $(".slide_qie li").click(function(){

            $(this).addClass("select").siblings().removeClass("select");
            var def = $(this);
            $("input[name=spec_id]").val(def.attr('data-id'));
            $("#sp-sh-img").attr('src',def.attr('data-img'));
            $("#sp-sh-tit").html(def.attr('data-title'));
            $("#onex-tit").html(def.attr('data-title'));
            var price = parseFloat(def.attr('data-price'));
            var group_price = parseFloat(def.attr('data-group-price'));
            $("input[name=price]").val(price);
            $("input[name=group_price]").val(group_price);
            var num = parseInt($("input[name=num]").val());

            $(".normal-btn .p1").html(price*num);
            $(".group-btn .p1").html(group_price*num);
            $("#onex-se").html('已选');
            $("#onex-num").html('x'+num);
        });
        //立即购买提交
        $(".subbtn").click(function () {
            if($(".subbtn").hasClass('sending')){
                $.Toast('提示','购买数据提交中请稍候','warning');
                return false;
            }
            var id = "{$goods._id}";
            var spec_id = $("input[name=spec_id]").val();
            var num = $("input[name=num]").val();;
            var type = 1;
            $.ajax({
                type:'post',
                url:"{:url('Goods/index')}",
                data:{id:id,spec_id:spec_id,num:num,type:type},
                cache:false,
                dataType:'JSON',
                success:function(data){
                    $(".subbtn").removeClass('sending');
                    if(data.status==0){
                        var url = "{:url('Goods/confirm')}?id="+id+"&spec_id="+spec_id+"&num="+num+"&type="+type;
                        window.location.href=url;
                    }else{
                        $.Toast('提示',data.info,'error');
                    }
                },
                error:function(e){
                    $(".subbtn").removeClass('sending');
                },
                beforeSend:function(e){
                    $(".subbtn").addClass('sending');
                }
            });
        });
		//团购
        $(".subbtn2").click(function () {
            if($(".subbtn2").hasClass('sending')){
                $.Toast('提示','购买数据提交中请稍候','warning');
                return false;
            }
            var id = "{$goods._id}";
            var spec_id = $("input[name=spec_id]").val();
            var num = $("input[name=num]").val();
            var group_id = $("input[name=group_id]").val();
            var type = 2;
            $.ajax({
                type:'post',
                url:"{:url('Goods/index')}",
                data:{id:id,spec_id:spec_id,num:num,group_id:group_id,type:type},
                cache:false,
                dataType:'JSON',
                success:function(data){
                    $(".subbtn2").removeClass('sending');
                    if(data.status==0){
                        var url = "{:url('Goods/confirm')}?id="+id+"&spec_id="+spec_id+"&num="+num+"&type="+type+"&group_id="+group_id;
                        window.location.href=url;
                    }else{
                        $.Toast('提示',data.info,'error');
                    }
                },
                error:function(e){
                    $(".subbtn2").removeClass('sending');
                },
                beforeSend:function(e){
                    $(".subbtn2").addClass('sending');
                }
            });
        });
        //拼团滚动
        $('.swap').html($('.news_li').html());
        x = $('.news_li');
        y = $('.swap');
        h = $('.news_li li').length * 112; //19为每个li的高度
        setTimeout(b,3000);//滚动间隔时间 现在是3秒
    });

    function b(){
        t = parseInt(x.css('top'));
        y.css('top','112px');
        x.animate({top: t - 112 + 'px'},'slow');	//112为每个li的高度
        if(Math.abs(t) == h-112){ //112为每个li的高度
            y.animate({top:'0px'},'slow');
            z=x;
            x=y;
            y=z;
        }
        setTimeout(b,5000);//滚动间隔时间 现在是3秒
    }

    //页面滚动
    var comTop = $("#comment").offset().top;
    var deTop = $("#detail").offset().top;
    $(".sli a").click(function () {
        var num = $(".sli a").index(this);
        if(num==0){
            $("body,html").animate({
                scrollTop:0
            });
        }else if(num==1){
            $("body,html").animate({
                scrollTop:comTop
            });
        }else{
            $("body,html").animate({
                scrollTop:deTop
            });
        }
    });
    //页面滚动
    $(window).scroll(function() {
        //为了保证兼容性，这里取两个值，哪个有值取哪一个
        //scrollTop就是触发滚轮事件时滚轮的高度
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        if(scrollTop<(comTop-10)){
            $(".sli a").removeClass('select');
            $(".sli a").eq(0).addClass('select');
        }else if(scrollTop >= (comTop-10) && scrollTop < (deTop-10)){
            $(".sli a").removeClass('select');
            $(".sli a").eq(1).addClass('select');
        }else{
            $(".sli a").removeClass('select');
            $(".sli a").eq(2).addClass('select');
        }
    })
</script>